home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL1.toast / Technical Documentation / develop / develop Issue 22 / develop Issue 22 code / PCI Driver Sample.sea / PCI Driver Sample / NCR_DriverProject / Src / PublishDriverDebugInfo.c / PublishDriverDebugInfo.c
Encoding:
C/C++ Source or Header  |  1995-07-24  |  2.5 KB  |  69 lines  |  [TEXT/MPCC]

  1. /*                                    PublishDriverDebugInfo.c                            */
  2. /*
  3.  * PublishDriverDebugInfo.c
  4.  * Copyright © 1994-95 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | This function shows how to store a private property into the Name Registry,        |
  9.       | replacing any existing instance of this property. The property contains a pointer    |
  10.       | to the driver globals, which a test application may use for debugging.             |
  11.     .___________________________________________________________________________________.
  12. */
  13.  
  14. #include "NCRDriverPrivate.h" 
  15.  
  16. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  17.  * Store a private property into the name registry with a pointer to our globals. The
  18.  * test function (or MacsBug) can use this for debugging. Errors are logged and ignored.
  19.  */
  20. void
  21. PublishDriverDebugInfo(void)
  22. {
  23.         OSErr                    status;
  24.         DriverGlobalPtr            driverGlobalPtr;
  25.         RegPropertyValueSize    size;
  26.  
  27.         Trace(PublishDriverDebugInfo);
  28.         /*
  29.          * Globalize the script so that the test driver can locate it using the
  30.          * Name Registry.
  31.          */
  32.         GLOBAL.ncrSCSIScriptSize = gNCRSCSIScriptSize;
  33.         driverGlobalPtr = &GLOBAL;
  34.         /*
  35.          * Does the property currently exist (with the correct size)?
  36.          */
  37.         status = RegistryPropertyGetSize(        /* returns noErr if the property exists    */
  38.                     &GLOBAL.deviceEntry,
  39.                     kDriverGlobalsPropertyName,
  40.                     &size
  41.                 );
  42.         if (status == noErr) {
  43.             /*
  44.              * Replace the current value of the property with its new value. In this
  45.              * example, we are replacing the entire value and, potentially, changing
  46.              * its size. In production software, you may need to read an existing
  47.              * property and modify its contents. This shouldn't be too hard to do.
  48.              */
  49.             status = RegistryPropertySet(        /* Update existing value                */
  50.                         &GLOBAL.deviceEntry,                    /* RegEntryID            */
  51.                         kDriverGlobalsPropertyName,                /* Property name        */
  52.                         (RegPropertyValue *) &driverGlobalPtr,    /* -> Property contents    */
  53.                         sizeof driverGlobalPtr                    /* Property size        */
  54.                     );
  55.             CheckStatus(status, "\pPublishDebugInfo - RegistryPropertySet");
  56.         }
  57.         else {
  58.             status = RegistryPropertyCreate(    /* Make a new property                    */
  59.                         &GLOBAL.deviceEntry,                    /* RegEntryID            */
  60.                         kDriverGlobalsPropertyName,                /* Property name        */
  61.                         (RegPropertyValue *) &driverGlobalPtr,    /* -> Property contents    */
  62.                         sizeof driverGlobalPtr                    /* Property size        */
  63.                     );
  64.             CheckStatus(status, "\pPublishDebugInfo - RegistryPropertyCreate");
  65.         }
  66. }
  67.  
  68.  
  69.